﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using Hxsoft.AppV1.Module;

namespace Hxsoft.AppV1.Admin.ArticleManage.Controls
{
	public partial class ModifyNavigation : BaseUserControl
	{
		#region property
		/// <summary>
		/// 当前的导航项键值。
		/// </summary>
		public string CurrentKey
		{
			get { return NavigationBar.CurrentKey; }
			set { NavigationBar.CurrentKey = value; }
		}

		/// <summary>
		/// 文章标识。
		/// </summary>
		public int ArticleID
		{
			get
			{
				object oArticleID = ViewState["ArticleID"];
				return oArticleID == null ? default(int) : (int)oArticleID;
			}
			set { ViewState["ArticleID"] = value; }
		}

		/// <summary>
		/// 模块标识。
		/// </summary>
		public int? ModuleID
		{
			get
			{
				object oModuleID = ViewState["ModuleID"];
				if (oModuleID == null)
					return null;
				else
					return (int)oModuleID;
			}
			set { ViewState["ModuleID"] = value; }
		}
		#endregion

		protected void Page_Load(object sender, EventArgs e)
		{
			if (!IsPostBack)
			{
				this.DataBind();

				if (ArticleID <= 0)
				{
					NavigationBar.Visible = false;

					return;
				}

				BindNavigationData();

			}
		}

		protected void BindNavigationData()
		{
			string queryString = "?ArticleID=" + ArticleID + "&InfoType=" + Articles.INFO_TYPE + "&InfoID=" + ArticleID;
			if (ModuleID.HasValue)
				queryString += "&ModuleID=" + ModuleID.Value;

			NavigationBar.NavigationItems.Add("ModifyArticle", new OperationNavigationItem("信息修改", "~/ArticleManage/ModifyArticle.aspx" + queryString));
			NavigationBar.NavigationItems.Add("ModifyComment", new OperationNavigationItem("评论修改", "~/CommentManage/CommentList.aspx" + queryString));

			if (ModuleID.HasValue)
				NavigationBar.NavigationItems.Add("ReleaseSetting", new OperationNavigationItem("发布设置", "~/ArticleManage/ReleaseSetting.aspx" + queryString));

			//NavigationBar.NavigationItems.Add("VoteList", new OperationNavigationItem("投票列表", "~/VoteManage/VoteList.aspx" + queryString + "&TypeCode=OnlinePoll"));
		}
	}
}